home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 414_02 / portable / endwin.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-19  |  2.2 KB  |  91 lines

  1. #define CURSES_LIBRARY    1
  2. #include <curses.h>
  3. #ifdef UNIX
  4. #define NOTLIB
  5. #include <defs.h>
  6. #include <term.h>
  7. #endif
  8. #undef    endwin
  9.  
  10. #ifdef PDCDEBUG
  11. char *rcsid_endwin = "$Header: C:\CURSES\portable\RCS\endwin.c 2.1 1993/06/18 20:19:50 MH Rel MH $";
  12. #endif
  13.  
  14.  
  15.  
  16.  
  17. /*man-start*********************************************************************
  18.  
  19.   endwin()    - restore initial terminal environment
  20.  
  21.   X/Open Description:
  22.      A program should always call endwin() before exiting or
  23.      escaping from curses mode temporarily.  This routine will
  24.      restore tty modes, move the cursor to the lower left corner
  25.      of the screen and reset the terminal into the proper non-visual
  26.      mode.  To resume curses after a temporary escape, refresh() or
  27.      doupdate() should be called.
  28.  
  29.   PDCurses Description:
  30.      At this time, endwin() must be followed by a call to initscr()
  31.      for temporary escapes.
  32.  
  33.      In addition, endwin() will resize the screen, if necessary.
  34.  
  35.   X/Open Return Value:
  36.      The endwin() function returns OK on success and ERR on error.
  37.  
  38.   X/Open Errors:
  39.      No errors are defined for this function.
  40.  
  41.   Portability:
  42.      PDCurses    int endwin( void );
  43.      X/Open Dec '88    int endwin( void );
  44.      BSD Curses    
  45.      SYS V Curses    
  46.  
  47. **man-end**********************************************************************/
  48.  
  49. int    endwin(void)
  50. {
  51. #ifdef PDCDEBUG
  52.     if (trace_on) PDC_debug("endwin() - called\n");
  53. #endif
  54.  
  55.     PDC_scr_close();
  56. /*    resetty();*/
  57.     if (_cursvar.orig_font != _cursvar.font)  /* screen has not been resized */
  58.         {
  59.         PDC_set_font(_cursvar.orig_font);
  60.         resize(PDC_get_rows());
  61.         }
  62.  
  63.     _cursvar.visible_cursor = FALSE;    /* Force the visible cursor */
  64.     _cursvar.cursor = _cursvar.orig_cursor;
  65.     curson();
  66.     delwin(stdscr);
  67.     delwin(curscr);
  68.     stdscr = (WINDOW *)NULL;
  69.     curscr = (WINDOW *)NULL;
  70.     _cursvar.alive = FALSE;
  71.  
  72.     /*
  73.      * Position cursor so that the screen will not scroll until they hit
  74.      * a carriage return.
  75.      */
  76.     PDC_gotoxy(PDC_get_rows() - 2, 0);
  77. #ifdef    FLEXOS
  78.     _flexos_8bitmode();
  79. #endif
  80. /*    PDC_fix_cursor(_cursvar.orig_emulation);*/
  81. #ifdef UNIX
  82.     if (exit_ca_mode != NULL)
  83.         putp(exit_ca_mode);
  84. #endif
  85. #ifndef UNIX
  86.     if (_cursvar.orig_font != _cursvar.font)  /* screen has not been resized */
  87. #endif
  88.         reset_shell_mode();
  89.     return( OK );
  90. }
  91.